package logics 
{
	import constants.Events;
	import constants.utils;
	import flash.display.MovieClip;
	
	/**
	 * ...
	 * @author parasitic
	 */
	 
	public class Camera extends MovieClip 
	{
		private var move:int = 200;
		private var speed:int = 17;
		
		private var tween:Tween;
		private var goal:int;
		
		public function moveLeft():void
		{
			goal = this.x + move;
			
			if (goal <= utils.limit)
			{
				var properties:Object = { x: { start:this.x, end:goal, steps:speed }};
				tween = new Tween(this, properties, Tween.circleInOut, Events.CAMERA_MOVED);
				tween.start();

			}
			else
			{
				dispatchEvent( new CustomEvent(Events.CAMERA_MOVED));
			}	
		}
		
		public function moveRight():void
		{
			goal = x - move;
			
			if (goal >= -utils.limit)
			{
				var properties:Object = { x: { start:this.x , end:goal, steps:speed }};
				tween = new Tween(this, properties, Tween.circleInOut, Events.CAMERA_MOVED);
				tween.start();
			}
			else
			{
				dispatchEvent( new CustomEvent(Events.CAMERA_MOVED));
			}
		}
		
		public function moveUp():void
		{
			goal = y + move;
			if (goal <= utils.limit)
			{
				var properties:Object = { y: { start:this.y, end:goal, steps:speed }};
				tween = new Tween(this, properties, Tween.circleInOut, Events.CAMERA_MOVED);
				tween.start();
			}
			else
			{
				dispatchEvent( new CustomEvent(Events.CAMERA_MOVED));
			}
		}
		
		public function moveDown():void
		{
			goal = y - move;
			if (goal >= -utils.limit)
			{
				var properties:Object = { y: { start:this.y, end:goal, steps:speed }};
				tween = new Tween(this, properties, Tween.circleInOut, Events.CAMERA_MOVED);
				tween.start();
			}
			else
			{
				dispatchEvent( new CustomEvent(Events.CAMERA_MOVED));
			}
		}
		
		public function outline():void
		{
			graphics.lineStyle(20, 0x000000, 1);
			graphics.drawRect( -600, -600, 1600, 1600);
		}
	}

}